diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-26 10:40:24 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-26 23:09:20 +0100 |
commit | 9c95415de877af1430ab5b7123e11dedd0ea622c (patch) | |
tree | 0a4bad23e32235523c9164a6094c0edea7f03f25 /comphelper | |
parent | a23a7eea5cfcdc50d09be248828cb1e6293e5ebb (diff) |
Let comphelper::Base64::decode* take std::u16string_view
Change-Id: I5b04f7adf11c61f52b7bfb0f52c8c075f838f0f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127480
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/qa/unit/base64_test.cxx | 6 | ||||
-rw-r--r-- | comphelper/qa/unit/test_hash.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/base64.cxx | 10 | ||||
-rw-r--r-- | comphelper/source/misc/docpasswordhelper.cxx | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/comphelper/qa/unit/base64_test.cxx b/comphelper/qa/unit/base64_test.cxx index 31e865a370a6..a1cd5d0006be 100644 --- a/comphelper/qa/unit/base64_test.cxx +++ b/comphelper/qa/unit/base64_test.cxx @@ -71,17 +71,17 @@ void Base64Test::testBase64Decode() uno::Sequence<sal_Int8> decodedSequence; uno::Sequence<sal_Int8> expectedSequence = { 0, 0, 0, 0, 0, 1, 2, 3 }; - comphelper::Base64::decode(decodedSequence, "AAAAAAABAgM="); + comphelper::Base64::decode(decodedSequence, u"AAAAAAABAgM="); CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), std::cend(expectedSequence), std::cbegin(decodedSequence))); expectedSequence = { 5, 2, 3, 0, 0, 1, 2, 3 }; - comphelper::Base64::decode(decodedSequence, "BQIDAAABAgM="); + comphelper::Base64::decode(decodedSequence, u"BQIDAAABAgM="); CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), std::cend(expectedSequence), std::cbegin(decodedSequence))); expectedSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 }; - comphelper::Base64::decode(decodedSequence, "yB9NbwABAgM="); + comphelper::Base64::decode(decodedSequence, u"yB9NbwABAgM="); CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), std::cend(expectedSequence), std::cbegin(decodedSequence))); } diff --git a/comphelper/qa/unit/test_hash.cxx b/comphelper/qa/unit/test_hash.cxx index 0bcc3f8ed56c..64815ee56dc8 100644 --- a/comphelper/qa/unit/test_hash.cxx +++ b/comphelper/qa/unit/test_hash.cxx @@ -120,7 +120,7 @@ void TestHash::testSHA512_NoSaltNoSpin() // tdf#104250 https://bugs.documentfoundation.org/attachment.cgi?id=129104 void TestHash::testSHA512_saltspin() { - const OUString aHash = comphelper::DocPasswordHelper::GetOoxHashAsBase64( "pwd", "876MLoKTq42+/DLp415iZQ==", 100000, + const OUString aHash = comphelper::DocPasswordHelper::GetOoxHashAsBase64( "pwd", u"876MLoKTq42+/DLp415iZQ==", 100000, comphelper::Hash::IterCount::APPEND, u"SHA-512"); CPPUNIT_ASSERT_EQUAL(OUString("5l3mgNHXpWiFaBPv5Yso1Xd/UifWvQWmlDnl/hsCYbFT2sJCzorjRmBCQ/3qeDu6Q/4+GIE8a1DsdaTwYh1q2g=="), aHash); } diff --git a/comphelper/source/misc/base64.cxx b/comphelper/source/misc/base64.cxx index 75274f5a73cb..d73465601adb 100644 --- a/comphelper/source/misc/base64.cxx +++ b/comphelper/source/misc/base64.cxx @@ -136,20 +136,20 @@ void Base64::encode(OUStringBuffer& aStrBuffer, const uno::Sequence<sal_Int8>& a } } -void Base64::decode(uno::Sequence<sal_Int8>& aBuffer, const OUString& sBuffer) +void Base64::decode(uno::Sequence<sal_Int8>& aBuffer, std::u16string_view sBuffer) { sal_Int32 nCharsDecoded = decodeSomeChars( aBuffer, sBuffer ); - OSL_ENSURE( nCharsDecoded == sBuffer.getLength(), "some bytes left in base64 decoding!" ); + OSL_ENSURE( sal_uInt32(nCharsDecoded) == sBuffer.size(), "some bytes left in base64 decoding!" ); } -sal_Int32 Base64::decodeSomeChars(uno::Sequence<sal_Int8>& rOutBuffer, const OUString& rInBuffer) +sal_Int32 Base64::decodeSomeChars(uno::Sequence<sal_Int8>& rOutBuffer, std::u16string_view rInBuffer) { - sal_Int32 nInBufferLen = rInBuffer.getLength(); + sal_Int32 nInBufferLen = rInBuffer.size(); sal_Int32 nMinOutBufferLen = (nInBufferLen / 4) * 3; if( rOutBuffer.getLength() < nMinOutBufferLen ) rOutBuffer.realloc( nMinOutBufferLen ); - const sal_Unicode *pInBuffer = rInBuffer.getStr(); + const sal_Unicode *pInBuffer = rInBuffer.data(); sal_Int8 *pOutBuffer = rOutBuffer.getArray(); sal_Int8 *pOutBufferStart = pOutBuffer; sal_Int32 nCharsDecoded = 0; diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx index a31f829ddfa9..f0f13ad74f1c 100644 --- a/comphelper/source/misc/docpasswordhelper.cxx +++ b/comphelper/source/misc/docpasswordhelper.cxx @@ -327,13 +327,13 @@ std::vector<unsigned char> DocPasswordHelper::GetOoxHashAsVector( css::uno::Sequence<sal_Int8> DocPasswordHelper::GetOoxHashAsSequence( const OUString& rPassword, - const OUString& rSaltValue, + std::u16string_view rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, std::u16string_view rAlgorithmName) { std::vector<unsigned char> aSaltVec; - if (!rSaltValue.isEmpty()) + if (!rSaltValue.empty()) { css::uno::Sequence<sal_Int8> aSaltSeq; comphelper::Base64::decode( aSaltSeq, rSaltValue); @@ -347,7 +347,7 @@ css::uno::Sequence<sal_Int8> DocPasswordHelper::GetOoxHashAsSequence( OUString DocPasswordHelper::GetOoxHashAsBase64( const OUString& rPassword, - const OUString& rSaltValue, + std::u16string_view rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, std::u16string_view rAlgorithmName) |