Skip to content

Completly insecure, no offence #2

@dustindog101

Description

@dustindog101

you're 'encryption algorhythem can easly be broken if someone finds the source code to this, all it does is shift the text inside of the file, if you want to be secure, when generating a key use sha-512

Here is my function for sha-512 you need to pass it the text and a salt
public static string hash(string inp,string salt) { SHA256 s = SHA256.Create();//creatae new sha256 byte[] hashit = Encoding.UTF8.GetBytes(inp + salt + pepper) ;//convert to bytes and add salt+pepper string hashed = Convert.ToBase64String(s.ComputeHash(hashit));//HASHHHH return hashed; }

When encrypting and Decryption you also make it dificult on your self while making it insecure, You should be sending the key, initlization vector and teh salt to the webserver, and encrypting files with AES-256 CBC here is the function i use for that aswell
Decryption is pretty straight forward just reverse that lol.
` public static byte[] encryptdata(byte[] bytearraytoencrypt, string key, string iv)//make it byte just in case we need to encrypt a file 🤷
{
try
{

            using (var dataencrypt = new AesCryptoServiceProvider())
            { //Block size : Gets or sets the block size, in bits, of the cryptographic operation.  
                dataencrypt.BlockSize = 128;
                //KeySize: Gets or sets the size, in bits, of the secret key  
                dataencrypt.KeySize = 128;
                //Key: Gets or sets the symmetric key that is used for encryption and decryption.  
                dataencrypt.Key = System.Text.Encoding.UTF8.GetBytes(key);
                //IV : Gets or sets the initialization vector (IV) for the symmetric algorithm  
                dataencrypt.IV = System.Text.Encoding.UTF8.GetBytes(iv);
                //Padding: Gets or sets the padding mode used in the symmetric algorithm  
                dataencrypt.Padding = PaddingMode.PKCS7;
                //Mode: Gets or sets the mode for operation of the symmetric algorithm  
                dataencrypt.Mode = CipherMode.CBC;
                //Creates a symmetric AES encryptor object using the current key and initialization vector (IV).  
                ICryptoTransform crypto1 = dataencrypt.CreateEncryptor(dataencrypt.Key, dataencrypt.IV);
                //TransformFinalBlock is a special function for transforming the last block or a partial block in the stream.   
                //It returns a new array that contains the remaining transformed bytes. A new array is returned, because the amount of   
                //information returned at the end might be larger than a single block when padding is added.  
                byte[] encrypteddata = crypto1.TransformFinalBlock(bytearraytoencrypt, 0, bytearraytoencrypt.Length);
                crypto1.Dispose();
                //return the encrypted data  
                return encrypteddata;

            }
        }
        catch (Exception)
        {

            throw;
        }
    }`

Anyways, not trying to be offencing just giving constructive critisisim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions