Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++;保存到文件Xcode的字符串的SHA1 基本上,我一直在圈子里努力地想让我的BASH脚本在C++程序中工作。我需要基本上创建一个程序,它将字符串的哈希值保存到文件。_C++_Xcode_Macos_Bash_Obfuscation - Fatal编程技术网

C++;保存到文件Xcode的字符串的SHA1 基本上,我一直在圈子里努力地想让我的BASH脚本在C++程序中工作。我需要基本上创建一个程序,它将字符串的哈希值保存到文件。

C++;保存到文件Xcode的字符串的SHA1 基本上,我一直在圈子里努力地想让我的BASH脚本在C++程序中工作。我需要基本上创建一个程序,它将字符串的哈希值保存到文件。,c++,xcode,macos,bash,obfuscation,C++,Xcode,Macos,Bash,Obfuscation,下面的bash脚本工作正常,但我需要对其进行模糊处理,使其成为一个可行的选项,因为我不希望用户能够将脚本拖到文本编辑器中,并查看发生了什么 因此,我需要将其编译成一个可执行程序来混淆代码 我有一个C++的基本知识,我喜欢用一个文本输入框和一个“go”按钮来设置它的接口。但是命令行可以帮助我学习这一步 我的bash脚本如下所示:- #!/bin/bash echo 'Enter a string :-'; <--- need to print this on

下面的bash脚本工作正常,但我需要对其进行模糊处理,使其成为一个可行的选项,因为我不希望用户能够将脚本拖到文本编辑器中,并查看发生了什么

因此,我需要将其编译成一个可执行程序来混淆代码

我有一个C++的基本知识,我喜欢用一个文本输入框和一个“go”按钮来设置它的接口。但是命令行可以帮助我学习这一步

我的bash脚本如下所示:- #!/bin/bash

echo 'Enter a string :-';                  <--- need to print this on the screen
read const_var1;                           <--- read user input

temp_var1="${const_var1//[[:blank:]]/}"    <--- setup variables

hash=$(echo -n $temp_var1 | openssl sha1);  <---- calculate SHA1 hash

serial=$(echo -n $hash | tr '[:lower:]' '[:upper:]';);   <---- convert hash to UPPERCASE

a="$hash";                    <---- save hash into a 
b=${a#*= };                   <---- move to b

echo 'HASH-' >> ~/Desktop/$temp_var1\.TEXTFILE;

echo '  <string>'$b"</string>" >> ~/Desktop/$temp_var1\.TEXTFILE;  <----- save hash to text file on the desktop with a set extension.

echo'输入字符串:-' 我真的不明白为什么要在这里进行模糊处理。
用户真正决定理解发生的事情,也可以用C++编译程序,尽管代价更高。

此外,我不明白为什么要使用
opensslsha1
而不是
sha1sum
。 此外,如果你计划使用C++,你可以很容易地重写BASH脚本,而不是调用它。

一个开始是C++中的Sa1计算,而其中<代码>包含< /代码>。 互联网上有一些类似代码的例子

如果您仍然希望直接运行bash脚本,那么可以使用(尽管名称不同,但不是Boost的一部分)或Qt中的QProcess。
您将运行脚本并提交用户输入。

如何实现boost?我下载了这个库,但我找不到Shan1.HPP,也不知道我会用它做什么。这是基本的C++和C++库使用,这在这里是不太可能的。特别是因为有很多教程比我以前解释得更好。尽管如此,我认为学习C++只是为了这个小案例,最有可能比使用PITA更多。C++是一种怪物,有它自己的方式。
 #include <iostream>     // include input output stream
 using namespace std;    // using the standard libraries 
 int main()              // start main funktion
{
    int a;              // declare variable types an names <----- needs to be a string not int.

    cout << "ENTER STRING :-\n";  // print message to screen    
    cin >> a;                                               // read variable A from user input.

    cout << "*HASHOFSTRING*";         // HERE I DONT KNOW WHAT TO DO. i need to access openssl and calculate the HASH IN UPPER CASE
}