为老式游戏生成密码保存

发布于 2024-12-01 10:47:43 字数 361 浏览 1 评论 0原文

我正在制作老式风格的 Flash 游戏,因为它太老式了,我希望它也能保存密码。不幸的是,我不能使用通常的解决方案 - 密码数组和相应的级别,其中之一是给 Arcadeprehacks 上的人带来困难,另一个是我希望能够保存游戏中并加载所有分数和生命。

关于密码,即我想要什么,

我需要一些解决方案将数字值编码为字符串,这些值是:

Lives - up to 2 digits
Score - 10 digits
Level number - 3 digits

它还可以采用 2 个附加值,可以是数字或文本,其他任何值都将转换为字符串。

它无法转换为任何字符串 - 其中只能包含数字和大写字母。

I'm making oldschool-styled flash game and as it's so oldschool, I want it also to have password saves. Unfortunately I can't use usual solution - array of passwords and corresponding levels, one of which is to give hard time for guys on Arcadeprehacks and the other is that I want to make possible to save in-game and load with all score and lives.

About passwords, i.e. What I want

I need some solution to encode number values to string, which values are:

Lives - up to 2 digits
Score - 10 digits
Level number - 3 digits

It can also take 2 additional values which can be numbers or text, anything else will be converted to string.

It can't be converted to ANY string - only numbers and capital letters can be in it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

漫雪独思 2024-12-08 10:47:43

您可以使用一些基本的解码器环逻辑来生成代码。零变成“F”,一变成“B”,等等。任何决心破解您的应用程序的人都可以翻译它,但这需要一些努力。

您可以通过添加无用的数据来进一步混淆数据。例如,在第三个字符位置放入一个随机字符,然后让解码器始终忽略第三个字符。

You could use some basic decoder ring logic to generate your codes. Zero becomes "F", one becomes "B", etc. Anyone who is determined to hack your app will be able to translate it, but it will take some effort.

You can further obfuscate your data by throwing in useless data. Throw in a random character in the third character position, for example, and then have your decoder always ignore the third character.

葬シ愛 2024-12-08 10:47:43

将密码保存在服务器端 SQL 上。

Keep pass-code on a server side SQL.

情绪操控生活 2024-12-08 10:47:43

据我了解,您想要的是这样的:

var livesString:String = new String(lives);

var scoreString:String = new String(score);

for(var i:int = scoreString.length; i < 10; i++)
{
    scoreString = "0"+scoreString;
}

var lvlNumString:String = new String(lvlNum);

for(var i:int = lvlNumString.length; i < 3; i++)
{
    lvlNumString = "0"+lvlNumString;
}

var password:String = livesString+scoreString+lvlNumString;

这应该给您一个包含您想要的数据的字符串。对于这两个“附加值”,只需将它们添加到 password 中,如下所示:

password += myVar.toString();

然后执行此操作以使任何文本大写:

password.toUpperCase();

顺便说一句,您说生命值应该“最多为 2”数字”,但如果您想要精确的 2 位数字,只需使用类似于上面的 for 循环即可。

From what I understand, what you want is this:

var livesString:String = new String(lives);

var scoreString:String = new String(score);

for(var i:int = scoreString.length; i < 10; i++)
{
    scoreString = "0"+scoreString;
}

var lvlNumString:String = new String(lvlNum);

for(var i:int = lvlNumString.length; i < 3; i++)
{
    lvlNumString = "0"+lvlNumString;
}

var password:String = livesString+scoreString+lvlNumString;

That should give you a string which contains the data you want. For the two "additional values", simply add them onto password like this:

password += myVar.toString();

And then do this to make any text uppercase:

password.toUpperCase();

By the way, you said that the value for lives should be "up to 2 digits", but if you want it exactly 2 digits, just use a for loop similar to those above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文