Sha256: 8d84f35bdbefd7274f64d968437d8379f2fc19f545b8761de825cfbaf7190ed5
Contents?: true
Size: 1010 Bytes
Versions: 9
Compression:
Stored size: 1010 Bytes
Contents
# Copyright (c) 2023 M.J.N. Corino, The Netherlands # # This software is released under the MIT license. module Wx class SecretStore # Wipes the secret data. def self.wipe(secret) if ::String === secret secret.bytesize.times { |i| secret.setbyte(i, 0) } end end end class SecretValue # Redefine the initialize method to auto-convert UTF-16/-32 strings to UTF-8 if possible. wx_init = self.instance_method(:initialize) define_method(:initialize) do | *args | if args.size == 1 && ::String === args.first unless args.first.encoding == ::Encoding::UTF_8 || args.first.encoding == ::Encoding::ASCII_8BIT # convert in place unless frozen if !args.first.frozen? args.first.encode!(::Encoding::UTF_8) rescue nil else # create converted copy (args = [args.first.encode(::Encoding::UTF_8)]) rescue nil end end end wx_init.bind(self).call(*args) end end end
Version data entries
9 entries across 9 versions & 1 rubygems