-1

I'm getting an encrypted md5 base 64 string encrypted with a key, this encryption is done in .Net, I need to decrypt that string using swift 4, but i can't find the way to to this, has anyone know if this is possible?

Scott Arciszewski
  • 33,610
  • 16
  • 89
  • 206
Barcenas
  • 76
  • 1
  • 10
  • Possible duplicate of [How to convert string to MD5 hash using ios swift](https://stackoverflow.com/questions/32163848/how-to-convert-string-to-md5-hash-using-ios-swift) – Ryan Nov 27 '17 at 21:55
  • You can find so many examples with very quick search. Even in stackoverflow there are many answers about this. Please search before you ask. – Ryan Nov 27 '17 at 21:56
  • 4
    MD5 is a hash, not encryption. Hence it cannot be decrypted. What are you actually trying to do? – Sami Kuhmonen Nov 27 '17 at 21:58
  • 1
    To be even more clear here: MD5 is a one-way function. It is, by design, not reversible. That said, you then said "encrypted with a key." MD5 has no key, so you have clearly not described the precise function that was applied to this data. You need to provide the *exact* .NET code used to encode (or encrypt) this data in order to discuss how to reverse the process in Swift. There is no "generic" version of hashing or encrypting. You have to explain precisely how it was done with code, or it is meaningless. – Rob Napier Nov 28 '17 at 02:06

1 Answers1

2

MD5 is what's known as a hashing algorithm, which is fundamentally different from an encryption algorithm. It was designed to be a one-way process whereas encryption can be decrypted to obtain the original data.

If you're looking to decrypt the data passed from .Net then it's going to need to be passed as encrypted, not hashed. There are many encryption options to choose from and some of the more popular ones are easily incorporated into a .Net project via NuGet.

If you have the key and the string, and need to ensure the hash sent wasn't tampered with then the link Ryan posted in the comments is what you're looking for.

user8675309
  • 591
  • 1
  • 6
  • 24