Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37875993
en ru br
Репозитории ALT
S:0.2-alt1
5.1: 0.1-alt4
4.1: 0.1-alt2.M41.1
4.0: 0.1-alt2.M40.1
www.altlinux.org/Changes

Группа :: Работа с текстами
Пакет: nxscramble

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064121326436720014520gustar00rootroot0000000000000052 comment=d28fe54986acdc2be445fc79892862896fb5211d
nxscramble-0.1/000075500000000000000000000000001213264367200135145ustar00rootroot00000000000000nxscramble-0.1/.gear-rules000075500000000000000000000000061213264367200155620ustar00rootroot00000000000000tar: .nxscramble-0.1/CMakeLists.txt000075500000000000000000000007321213264367200162610ustar00rootroot00000000000000PROJECT(nxscramble)

SET(CMAKE_VERBOSE_MAKEFILE OFF)
SET(CMAKE_INSTALL_PREFIX "/")
SET(CMAKE_SKIP_RPATH OFF)

FIND_PACKAGE(LibXml2 REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED)

add_definitions(${QT_DEFINITIONS} ${LIBXML2_DEFINITIONS})

include_directories(${QT_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})

add_executable(nxscramble nxscramble.cpp)

TARGET_LINK_LIBRARIES(nxscramble ${QT_QTCORE_LIBRARY_RELEASE} ${LIBXML2_LIBRARIES})
INSTALL(TARGETS nxscramble RUNTIME DESTINATION usr/bin)
nxscramble-0.1/build/000075500000000000000000000000001213264367200146135ustar00rootroot00000000000000nxscramble-0.1/build/.gitignore000075500000000000000000000000011213264367200165750ustar00rootroot00000000000000*nxscramble-0.1/nxscramble.cpp000075500000000000000000000074721213264367200163730ustar00rootroot00000000000000/***************************************************************************
* Copyright (C) 2008 by п°п╟п╨я│п╦п╪ п≤п╡п╟п╫п╬п╡ *
* ivanov@cg.ru *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QtCore/QString>
#include <QtCore/QTime>
#include <libxml/uri.h>
#include <stdio.h>
#include <error.h>
#include <errno.h>

const int numValidCharList = 85;
const QString dummyString = "{{{{";


QString encodePassword(const QString& p)
{
QString sPass = ":";
QString sTmp = "";


if (p.isEmpty())
{
return "";
}


for (unsigned int i = 0; i < p.length(); i++)
{
char c = p.at(i).toAscii();


sTmp.sprintf("%d:", (c + i + 1));
sPass += sTmp;
sTmp = "";
}


return sPass;
}


static char validCharList[numValidCharList] =
{
'!', '#', '$', '%', '&', '(', ')', '*', '+', '-',
'.', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', ':', ';', '<', '>', '?', '@', 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', ']', '_', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '{', '|', '}'
};


static int findCharInList(char c)
{
int i = -1;


for (int j = 0; j < numValidCharList; j++)
{
if (validCharList[j] == c)
{
i = j;


return i;
}
}


return i;
}


static char getRandomValidCharFromList()
{
int k = QTime::currentTime().second();


return validCharList[k];
}


const char* scrambleString(const QString& s)
{
QString sRet = "";

if (s.isNull() || s.isEmpty())
{
return s.toAscii().data();
}

QString str = encodePassword(s);

if (str.length() < 32)
{
str += dummyString;
}

for (int iR = (str.length() - 1); iR >= 0; iR--)
{
//
// Reverse string
//

sRet += str.at(iR);
}

if (sRet.length() < 32)
{
sRet += dummyString;
}

int k = getRandomValidCharFromList();
int l = k + sRet.length() - 2;

sRet.insert(0, k);

for (int i1 = 1; i1 < (int)sRet.length(); i1++)
{
int j = findCharInList(sRet.at(i1).toLatin1());

if (j == -1)
{
return s.toAscii().data();
}

int i = (j + l * (i1 + 1)) % numValidCharList;

sRet[i1]=validCharList[i];
}


char c = getRandomValidCharFromList() + 2;


sRet.append(c);
return (const char *) xmlEncodeEntitiesReentrant(NULL,xmlCharStrdup(sRet.toAscii().data()));
}

int main (int ac, char *av[])
{
if (2 == ac)
{
printf("%s\n",scrambleString(QString(av[1])));
}
else
{
error(1, errno, "Invalid number of arguments");
}
return 0;
}
nxscramble-0.1/nxscramble.spec000064400000000000000000000020571213264367200165320ustar00rootroot00000000000000Name: nxscramble
Version: 0.1
Release: alt4.qa1

Summary: Utility which scrambles password string same way as Nomachine NX client
Group: Text tools
License: GPL

Source: %name-%version.tar

Url: http://www.nomachine.com/ar/view.php?ar_id=AR01C00125
Packager: Lenar Shakirov <snejok@altlinux.org>

BuildRequires: libxml2-devel libqt4-devel cmake gcc-c++ qt4-settings

%description
Small tool which scrambles an plain text string the same way as Nomachine
NX Client does it.

%prep
%setup

%build
cd build
cmake ..
%make

%install
cd build
%makeinstall DESTDIR=%buildroot

%files
%_bindir/nxscramble

%changelog
* Mon Apr 15 2013 Dmitry V. Levin (QA) <qa_ldv@altlinux.org> 0.1-alt4.qa1
- NMU: rebuilt for debuginfo.

* Tue May 26 2009 Lenar Shakirov <snejok@altlinux.ru> 0.1-alt4
- Url added. Thanks to repocop!

* Fri Dec 26 2008 Lenar Shakirov <snejok@altlinux.ru> 0.1-alt3
- BuildRequires updated

* Fri Dec 26 2008 Lenar Shakirov <snejok@altlinux.ru> 0.1-alt2
- New packager

* Wed Mar 26 2008 Maxim Ivanov <redbaron@altlinux.ru> 0.1-alt1
- Initial build for Sisyphus

 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin