简体   繁体   English

如何使用Excel / VBA将字符串压缩/解压缩为32个字符的字母数字字符串?

[英]How can I compress/decompress a string into a 32-character alphanumeric string using Excel/VBA?

I hope I'm asking the right question, but if not I'd like to clarify what I'm trying to do. 我希望我问的是正确的问题,但如果不是,我想澄清一下我想做的事情。

I'd like to take a string of alphabetic text and convert it into a 32-character alphanumeric string of text. 我想获取一串字母文本并将其转换为32个字符的字母数字文本字符串。 I would then like to covert that 32-character alphanumeric string of text back to the original text. 然后,我想将32个字符的字母数字字符串转换回原始文本。 I only care about shortening the length. 我只关心缩短长度。 I don't care about security. 我不在乎安全性。 I don't care about maintaining the case sensitivity of the original string. 我不在乎保持原始字符串区分大小写。

Is something like this even possible or am I trying to create bytes of data out of thin air? 这样的事情是否可能发生?还是我想凭空创建字节数据?

In base 62 (62 different characters), a string of 32 characters can represent 62^32 different values, which comes out to about 3.7922554e+57. 在基数62(62个不同的字符)中,一串32个字符可以表示62 ^ 32个不同的值,大约为3.7922554e + 57。

An arbitrary string in your origin alphabet of 28 characters (AZ plus space and period) of length 39 could be any of 2.7489271e+56 different patters. 您的原始字母中长度为39的28个字符(AZ加空格和句点)中的任意字符串可以是2.7489271e + 56个不同的模式。 If the length is increased to 40 characters, there are 7.6969959e+57 different patterns. 如果长度增加到40个字符,则有7.6969959e + 57个不同的模式。

What this means: The theoretical maximum length arbitrary string you could store is 39 characters. 这意味着什么:您可以存储的理论上最大长度的任意字符串是39个字符。 In practice, it would almost certainly be less than that. 实际上,几乎可以肯定会少于那个。 Note that the example string you provided in the comments is 55 characters long. 请注意,您在注释中提供的示例字符串长度为55个字符。

This is for an arbitrary string. 这是用于任意字符串的。 Compression algorithms often look for patterns that can be compressed further. 压缩算法通常会寻找可以进一步压缩的模式。 But that depends on the nature of the string being compressed. 但这取决于要压缩的字符串的性质。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM