Fixed clazy warnings: pass large objects by reference to const.

This commit is contained in:
Mat Sutcliffe
2018-12-17 16:43:54 +00:00
parent e40af8132c
commit 9f85a7b560
27 changed files with 49 additions and 47 deletions

View File

@@ -82,7 +82,7 @@ namespace BlackMisc
return encryptToByteArray(plaintextArray);
}
QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext)
QByteArray SimpleCrypt::encryptToByteArray(const QByteArray &plaintext)
{
if (m_keyParts.isEmpty())
{
@@ -159,7 +159,7 @@ namespace BlackMisc
return cypherString;
}
QString SimpleCrypt::encryptToString(QByteArray plaintext)
QString SimpleCrypt::encryptToString(const QByteArray &plaintext)
{
QByteArray cypher = encryptToByteArray(plaintext);
QString cypherString = QString::fromLatin1(cypher.toBase64());
@@ -175,7 +175,7 @@ namespace BlackMisc
return plaintext;
}
QString SimpleCrypt::decryptToString(QByteArray cypher)
QString SimpleCrypt::decryptToString(const QByteArray &cypher)
{
QByteArray ba = decryptToByteArray(cypher);
QString plaintext = QString::fromUtf8(ba, ba.size());
@@ -191,7 +191,7 @@ namespace BlackMisc
return ba;
}
QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher)
QByteArray SimpleCrypt::decryptToByteArray(const QByteArray &cypher)
{
if (m_keyParts.isEmpty())
{

View File

@@ -147,7 +147,7 @@ namespace BlackMisc
a cyphertext the result. The result is a base64 encoded version of the binary array that is the
actual result of the encryption, so it can be stored easily in a text format.
*/
QString encryptToString(QByteArray plaintext) ;
QString encryptToString(const QByteArray &plaintext) ;
/**
Encrypts the @arg plaintext string with the key the class was initialized with, and returns
@@ -165,7 +165,7 @@ namespace BlackMisc
This method returns a byte array, that is useable for storing a binary format. If you need
a string you can store in a text file, use encryptToString() instead.
*/
QByteArray encryptToByteArray(QByteArray plaintext) ;
QByteArray encryptToByteArray(const QByteArray &plaintext) ;
/**
Decrypts a cyphertext string encrypted with this class with the set key back to the
@@ -192,7 +192,7 @@ namespace BlackMisc
If an error occured, such as non-matching keys between encryption and decryption,
an empty string or a string containing nonsense may be returned.
*/
QString decryptToString(QByteArray cypher) ;
QString decryptToString(const QByteArray &cypher) ;
/**
Decrypts a cyphertext binary encrypted with this class with the set key back to the
@@ -201,7 +201,7 @@ namespace BlackMisc
If an error occured, such as non-matching keys between encryption and decryption,
an empty string or a string containing nonsense may be returned.
*/
QByteArray decryptToByteArray(QByteArray cypher) ;
QByteArray decryptToByteArray(const QByteArray &cypher) ;
/**
Enum to describe options that have been used for the encryption. Currently only one, but