c# - Convert String to Int and back to String -


i trying convert email string int32 hash using hashidsnet.

finally, revert process email again ... tried following:

hashidsnet.hashids hash = new hashidsnet.hashids(); string email = "john.smith@xyz.com"; byte[] bytes = encoding.utf8.getbytes(email); int32 number = bitconverter.toint32(bytes, 0); string hashed = hash.encrypt(number); int32[] numbers = hash.decrypt(hashed); byte[] newbytes = bitconverter.getbytes(numbers[0]); string newemail = encoding.utf8.getstring(newbytes); 

somehow newemail becomes "john".

what missing?

you convert first 4 bytes (int32 32-bit type) number, encrypt, decrypt , decode them again. 4 bytes in utf-8 fit john quite nicely. need array of integers , in case can use byte[].


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -