public string Encode(EncodeAlgorithm algorithm, string value) { string result = string.Empty; if (string.IsNullOrWhiteSpace(value)) { throw new Exception("Wrong Input"); } try { byte[] source = Encoding.Default.GetBytes(value); switch (algorithm) { case EncodeAlgorithm.SHA256: result = SHA256_Hash(source); break; case EncodeAlgorithm.SHA384: result = SHA384_Hash(source); break; case EncodeAlgorithm.SHA512: default: result = SHA512_Hash(source); break; } } catch (Exception ex) { throw ex; } return(result); }
public static string DecFromBinary(byte[] data, EncodeAlgorithm ea = DefaultEncodeAlgorithm, string pubKey = desPubKey) { switch (ea) { case EncodeAlgorithm.DES: return DesDecFromBinary(data, pubKey); } return DesDecFromBinary(data, pubKey); }
public static string Dec(string data, EncodeAlgorithm ea = DefaultEncodeAlgorithm, string pubKey = desPubKey) { return DecFromBinary(HexToBinary(data), ea, pubKey); }
public static byte[] EncToBinary(string data, EncodeAlgorithm ea = DefaultEncodeAlgorithm, string pubKey = desPubKey) { switch (ea) { case EncodeAlgorithm.DES: return DesEncToBinary(data, pubKey); } return DesEncToBinary(data, pubKey); }
public static string Enc(string data, EncodeAlgorithm ea = DefaultEncodeAlgorithm, string pubKey = desPubKey) { return BinaryToHex(EncToBinary(data, ea, pubKey)); }