private static string GeneratePassword(Types.EncryptionType encryptionType, PegaUser user) { switch (encryptionType) { case Types.EncryptionType.ApiKey_Public: return($"QZ{string.Join("d", user.Username.Reverse())}_V638uhWV"); case Types.EncryptionType.ApiKey_Private: return($"TZ{user.Username}V638{string.Join("b", user.CreatedDate.ToShortDateString().Replace("/", "").Reverse())}_$WV"); } return(string.Empty); }
private static string _vector = "xxx"; // Random private static void SetProperSaltAndVector(Types.EncryptionType encryptionType) { switch (encryptionType) { case Types.EncryptionType.ApiKey_Public: case Types.EncryptionType.ApiKey_Private: _salt = "xxx+"; _vector = "xxx"; return; } }
public static string Decrypt(string value, Types.EncryptionType encryptionType, PegaUser user) { SetProperSaltAndVector(encryptionType); switch (encryptionType) { case Types.EncryptionType.ApiKey_Public: return(Decrypt(value, GeneratePassword(encryptionType, user))); case Types.EncryptionType.ApiKey_Private: return(Decrypt(value, GeneratePassword(encryptionType, user))); } return(string.Empty); }