public String GenerateToken() { byte[] randomBytes = new byte[32]; RNGCryptoServiceProvider prng = new RNGCryptoServiceProvider(); prng.GetBytes(randomBytes); return(EncodingUtil.Base64Encode(randomBytes)); }
public String createSignature(String key, String data) { byte[] keyBytes = System.Text.Encoding.UTF8.GetBytes(key); byte[] hashValue; using (HMACSHA256 hmac = new HMACSHA256(keyBytes)) { hashValue = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(data)); } return(EncodingUtil.HexEncode(hashValue)); }
public String pbkdf2(String value, String salt, int iterations) { String hash = EncodingUtil.HexEncode(PBKDF2Sha256GetBytes( 32, System.Text.Encoding.UTF8.GetBytes(value), System.Text.Encoding.UTF8.GetBytes(salt), iterations)); return(hash); }