Статус: Участник
  Группы: Участники
 Зарегистрирован: 25.01.2008(UTC) Сообщений: 29 Откуда: Moscow
  
	 
	
     | 
    
        
            
		      
                Не нашел поиском, поэтому пишу.
  Есть ли возможность вызвать из командной строки или другим способом мастер копирования контейнера закрытого ключа? Того, который можно вызвать с вкладки "Сервис". Нужно для автоматизации действий. 
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
            
        
            
            
    
        
	Статус: Участник
  Группы: Участники
 Зарегистрирован: 25.01.2008(UTC) Сообщений: 29 Откуда: Moscow
  
	 
	
     | 
    
        
            
		      
                Не дождался ответа, на bat-файле реализовать не получилось - не ас bat, накидал на c++, может кому пригодится. Но все равно жду ответа по поводу возможности вызова сервисных функций. Код:
std::vector<std::string> split(const std::string &string)
{
    std::stringstream stream(string);
    std::vector<std::string> res;
    while (1){
        std::string line;
        std::getline(stream,line);
        if (!stream.good())
            break;
        res.push_back(line);
    }
    return res;
}
std::string clear(const std::string &string)
{
	int one = 0, two = 0, i = -1;
	while (1){
		i++;
		if (string[i]==' '){
			two = one;
			continue;
		}
		else{
			one = 1;
			if(two) return string.substr(i);
		}
	}
}
int exit()
{
	printf("\npress Enter for exit...\n");
	std::string s;
	std::getline(std::cin, s);
	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	const char* csptest = "\"c:\\Program Files\\Crypto Pro\\CSP\\csptest.exe\"";
	const char* csp_enum = " -enum -info -type PP_ENUMCONTAINERS";
	const char* csp_keycopy = " -keycopy";
	const char* csp_keycopy1 = " -src ";
	const char* csp_keycopy2 = " -dest ";
	char* command;
	int command_length;
	command_length = strlen(csptest) + strlen(csp_enum) + 1;
	command = new char[command_length];
	memset(command, 0, command_length);
	strcat(command, csptest);
	strcat(command, csp_enum);
	FILE* pipe;
	char buffer[256];
	std::string result;
	pipe = _popen(command, "r");
    if (!pipe) return 1;
    result = "";
    while(!feof(pipe)) {
        if(fgets(buffer, 256, pipe) != NULL)
                result += buffer;
    }
    _pclose(pipe);
	printf("\n");
	printf(result.c_str());
	printf("\n");
	std::vector<std::string> containers;
	
	std::vector<std::string> v = split(result);
	for(int i=5; i<v.size() - 3; i++)
	{
		containers.push_back(clear(v[i]));		
	}
	printf("Source containers:\n");
	for(int i=0; i<containers.size(); i++)
		printf("[%i] %s\n", i+1, containers[i].c_str());
	printf("Input container number: ");
	std::string container_nstring;
	std::getline(std::cin, container_nstring);
	int container_number = std::atoi(container_nstring.c_str());
	
	if(container_number<=0 || container_number>containers.size())
	{
		printf("[error] invalid container number\n");
		return exit();
	}
	std::string container_src_string(containers[container_number - 1]);
	printf("Input destination container name: ");
	std::string container_dest_string;
	std::getline(std::cin, container_dest_string);
	
	command_length = strlen(csptest) + strlen(csp_keycopy) + 
		strlen(csp_keycopy1) + container_src_string.size() +
		strlen(csp_keycopy2) + container_dest_string.size() +
		1;
	command = new char[command_length];
	memset(command, 0, command_length);
	strcat(command, csptest);
	strcat(command, csp_keycopy);
	strcat(command, csp_keycopy1);
	strcat(command, container_src_string.c_str());
	strcat(command, csp_keycopy2);
	strcat(command, container_dest_string.c_str());
	pipe = _popen(command, "r");
    if (!pipe) return 1;
    result = "";
    while(!feof(pipe)) {
        if(fgets(buffer, 256, pipe) != NULL)
                result += buffer;
    }
    _pclose(pipe);
	printf("\n");
	printf(result.c_str());
	printf("\n");
	
    return exit();
}
 
  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
    
	                           
	
    
        Быстрый переход
         
	
    
    Вы не можете создавать новые темы в этом форуме.
	
	Вы не можете отвечать в этом форуме.
	
	Вы не можете удалять Ваши сообщения в этом форуме.
	
	Вы не можете редактировать Ваши сообщения в этом форуме.
	
	Вы не можете создавать опросы в этом форуме.
	
	Вы не можете голосовать в этом форуме.
	
	
    
    
        Important Information:
        The Форум КриптоПро uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
        
        
More Details
        Close