Show / Hide Table of Contents

Class SymmetricCryptography

Cryptoclass useful for easily encrypting/decrypting stuff.

Inheritance
System.Object
SymmetricCryptography
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GlitchedPolygons.Utilities
Assembly: UnityScriptsLibrary.dll
Syntax
public static class SymmetricCryptography

Methods

| Improve this Doc View Source

Decrypt(Byte[], String, String, Int32)

Decrypts an encrypted byte[] array using the specified key, salt and rfc iterations.

Note: the decryption can only succeed if you use the EXACT same key, salt and amount of rfc iterations; so make sure to NEVER lose those values!

If the decryption fails, the original input data is returned unmodified.

Declaration
public static byte[] Decrypt(byte[] data, string key, string salt, int rfcIterations)
Parameters
Type Name Description
System.Byte[] data

The encrypted data.

System.String key

The decryption key.

System.String salt

The salt that was used to encrypt the data,

System.Int32 rfcIterations

The amount of rfc iterations that were used to encrypt the data.

Returns
Type Description
System.Byte[]

The decrypted data, but if the decryption failed in some way, then the original input data is returned unmodified.

| Improve this Doc View Source

Encrypt(Byte[], String, String, Int32)

Encrypt data using a specific key and salt string.

Declaration
public static byte[] Encrypt(byte[] data, string key, string salt, int rfcIterations)
Parameters
Type Name Description
System.Byte[] data

The data you want to encrypt.

System.String key

The cryptographic key with which the data should be encrypted. Make this at least 32 characters long!

System.String salt

The crypto salt to use for key derivation (should also be at least 32 characters long).

System.Int32 rfcIterations

The amount of iterations that the System.Security.Cryptography.Rfc2898DeriveBytes algo should perform to derive the key.

Returns
Type Description
System.Byte[]

The encrypted bytes.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX