File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Common/PluginsCommon/Extensions
Generic/ReviewViewer/Application Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,16 @@ internal static byte[] MD5Bytes(this string s)
4141 }
4242 }
4343
44+ public static string ToHashedKey ( this string input )
45+ {
46+ using ( var sha = Security . Cryptography . SHA256 . Create ( ) )
47+ {
48+ var inputBytes = Encoding . UTF8 . GetBytes ( input ) ;
49+ var hashBytes = sha . ComputeHash ( inputBytes ) ;
50+ return Convert . ToBase64String ( hashBytes ) ;
51+ }
52+ }
53+
4454 internal static string GetSHA256Hash ( this string input )
4555 {
4656 using ( var sha = Security . Cryptography . SHA256 . Create ( ) )
@@ -50,6 +60,14 @@ internal static string GetSHA256Hash(this string input)
5060 }
5161 }
5262
63+ public static byte [ ] GetSHA256HashByte ( this string input )
64+ {
65+ using ( var sha = System . Security . Cryptography . SHA256 . Create ( ) )
66+ {
67+ return sha . ComputeHash ( Encoding . UTF8 . GetBytes ( input ) ) ;
68+ }
69+ }
70+
5371 internal static string UrlEncode ( this string str )
5472 {
5573 if ( string . IsNullOrEmpty ( str ) )
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ public async Task<ReviewsResponseDto> GetReviewsAsync(
3737 string cursor = "*" )
3838 {
3939 var cacheKey = $ "{ appId } _{ Serialization . ToJson ( options ) } _{ cursor } ";
40- var existingCache = _repository . Find ( x => x . CacheKey == cacheKey ) . FirstOrDefault ( ) ;
40+ var hashedCacheKey = cacheKey . ToHashedKey ( ) ;
41+ var existingCache = _repository . Find ( x => x . CacheKey == hashedCacheKey ) . FirstOrDefault ( ) ;
4142 if ( ! forceRefresh && existingCache != null && ( DateTime . UtcNow - existingCache . CreatedAt ) < _cacheDuration )
4243 {
4344 return existingCache . Response ;
@@ -53,7 +54,7 @@ public async Task<ReviewsResponseDto> GetReviewsAsync(
5354
5455 var newRecord = new ReviewsResponseRecord
5556 {
56- CacheKey = cacheKey ,
57+ CacheKey = hashedCacheKey ,
5758 Response = freshData
5859 } ;
5960
You can’t perform that action at this time.
0 commit comments