File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22
3+ import { createHash } from 'node:crypto' ;
4+
35import type {
46 HotReloadConfig ,
57 PluginStateSnapshot
@@ -136,21 +138,11 @@ class PluginStateManager {
136138 }
137139
138140 /**
139- * Calculate simple checksum for state verification
140- * WARNING: This is a simple hash for demo purposes.
141- * In production, use a cryptographic hash like SHA-256.
141+ * Calculate checksum for state verification using SHA-256.
142142 */
143143 private calculateChecksum ( state : Record < string , any > ) : string {
144- // Simple checksum using JSON serialization
145- // TODO: Replace with crypto.createHash('sha256') for production
146144 const stateStr = JSON . stringify ( state ) ;
147- let hash = 0 ;
148- for ( let i = 0 ; i < stateStr . length ; i ++ ) {
149- const char = stateStr . charCodeAt ( i ) ;
150- hash = ( ( hash << 5 ) - hash ) + char ;
151- hash = hash & hash ; // Convert to 32-bit integer
152- }
153- return hash . toString ( 16 ) ;
145+ return createHash ( 'sha256' ) . update ( stateStr ) . digest ( 'hex' ) ;
154146 }
155147
156148 /**
You can’t perform that action at this time.
0 commit comments