Skip to content

Commit

Permalink
Add basic messageDigest: to the LanguagePlatform
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Jun 18, 2024
1 parent f0e1095 commit c4216b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ PharoPlatform >> includesGlobalNamed: aSymbol [
^ Smalltalk globals includesKey: aSymbol
]

{ #category : 'message digest' }
PharoPlatform >> messageDigest: string [

^ SHA256 hashMessage: string
]

{ #category : 'accessing' }
PharoPlatform >> os [

Expand Down
15 changes: 15 additions & 0 deletions source/Buoy-Metaprogramming-Tests/LanguagePlatformTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down

0 comments on commit c4216b0

Please sign in to comment.