diff --git a/source/Buoy-Metaprogramming-Extensions/LanguagePlatform.class.st b/source/Buoy-Metaprogramming-Extensions/LanguagePlatform.class.st index b90ca05..a5b2ee9 100644 --- a/source/Buoy-Metaprogramming-Extensions/LanguagePlatform.class.st +++ b/source/Buoy-Metaprogramming-Extensions/LanguagePlatform.class.st @@ -55,6 +55,14 @@ LanguagePlatform >> includesGlobalNamed: aSymbol [ ^ self subclassResponsibility ] +{ #category : 'message digest' } +LanguagePlatform >> messageDigest: string [ + "Returns a message digest for the given string, the hashing algorithm can be platform specific. + The resulting digest mut be a byte array" + + ^ self subclassResponsibility +] + { #category : 'accessing' } LanguagePlatform >> os [ "Returns the underlying operating system abstraction" diff --git a/source/Buoy-Metaprogramming-Pharo-Extensions/PharoPlatform.class.st b/source/Buoy-Metaprogramming-Pharo-Extensions/PharoPlatform.class.st index aeb4b0f..77f1f48 100644 --- a/source/Buoy-Metaprogramming-Pharo-Extensions/PharoPlatform.class.st +++ b/source/Buoy-Metaprogramming-Pharo-Extensions/PharoPlatform.class.st @@ -36,6 +36,12 @@ PharoPlatform >> includesGlobalNamed: aSymbol [ ^ Smalltalk globals includesKey: aSymbol ] +{ #category : 'message digest' } +PharoPlatform >> messageDigest: string [ + + ^ SHA256 hashMessage: string +] + { #category : 'accessing' } PharoPlatform >> os [ diff --git a/source/Buoy-Metaprogramming-Tests/LanguagePlatformTest.class.st b/source/Buoy-Metaprogramming-Tests/LanguagePlatformTest.class.st index 12ac0b4..08dea49 100644 --- a/source/Buoy-Metaprogramming-Tests/LanguagePlatformTest.class.st +++ b/source/Buoy-Metaprogramming-Tests/LanguagePlatformTest.class.st @@ -86,6 +86,21 @@ LanguagePlatformTest >> testIncludesGlobalNamed [ #AnImplausibleGlobalName) ] +{ #category : 'tests' } +LanguagePlatformTest >> testMessageDigest [ + + self + assert: ( LanguagePlatform current messageDigest: '' ) + equals: + #[ 227 176 196 66 152 252 28 20 154 251 244 200 153 111 185 36 39 174 65 228 100 155 147 76 164 + 149 153 27 120 82 184 85 ]; + assert: + ( LanguagePlatform current messageDigest: 'The quick brown fox jumps over the lazy dog' ) + equals: + #[ 215 168 251 179 7 215 128 148 105 202 154 188 176 8 46 79 141 86 81 228 109 60 219 118 45 + 2 208 191 55 201 229 146 ] +] + { #category : 'tests' } LanguagePlatformTest >> testOSEnvironment [